Using Word Table Functions
From version 7.2, you can manipulate the content in Word tables. For reference, see MS Word Functions Library Objects.
The following Word table functions were added:
Add Table Last Row: Adds a new row to the end of the specified table in the Word document.
Clear Table Content: Clears the content of the specified table in the Word document.
Delete Table: Deletes the specified table in the Word document.
Delete Table Row: Deletes the specified row in the given table in the Word document.
Get Table Cell Text: Gets text from the specified cell in the table of the Word document.
Get Table Cells Count in Row: Gets the number of cells in the specified row in the table of the Word document.
Get Table Content: Returns a collection of rows that represents the content of the table in the Word document.
Get Table Rows Count: Gets the number of rows in the specified table in the Word document.
Get Tables Count: Gets a count of the tables in the Word document.
Insert Table Row Above: Inserts a new row with the specified number of cells above the existing row in the table of the Word document.
Insert Table Row Below: Inserts a new row with the specified number of cells below the existing row in the table of the Word document.
Set Table Cell Text: Sets text into the specified cell in the table of the Word document.
The example below includes additional custom functions that may be useful for your project.
To test the Word Table functions:
1. | Download the sample project here. |
2. | The sample project zip file includes several Word files with tables in to use as examples. |
3. | The sample project uses a MS Word custom type with various properties, for example, Cell count and Cell text, as well as functions that illustrate how to use the new data table functions. |
4. | The sample project also includes instances to manage the Active Document Name, Document Name and Document Text, as well as an instance of the MS Word custom type, and a Table Content instance which is a List of Row (found in Library Types > General > Row). The Table Content instance is used to retrieve all the content from a table. |
5. | Open one of the sample files, for example, repeat-multiple-table-rows-result.docx. |
6. | Run the project. |
7. | Click Get Active Doc to return the active document. |
8. | Click Get Document Tables Count to return the number of tables in the active document. |
9. | In Set Table Index, enter 1. |
10. | Click Get Document Table Rows Count. |
11. | Click Get Document Table Content. The content of the table is returned |
12. | Open Monitor. |
13. | Expand to view the table content in the Monitor. |
14. | Try the other functions in the callout. |